package com.zqxx.examine.common.utils;

import java.util.ArrayList;
import java.util.List;

import com.zqxx.examine.model.exam.Paper;

public class Population
{
  private int populationSize;
  private List<Paper> content;
  
  public int getPopulationSize()
  {
    return this.populationSize;
  }
  
  public void setPopulationSize(int populationSize)
  {
    this.populationSize = populationSize;
  }
  
  public List<Paper> getContent()
  {
    return this.content;
  }
  
  public void setContent(List<Paper> content)
  {
    this.content = content;
  }
  
  private List<Integer> choosePager()
  {
    List<Integer> nextGeneration = new ArrayList();
    double fitnessSum = 0.0D;
    List<Double> p = new ArrayList();
    for (Paper paper : this.content) {
      fitnessSum += paper.getFitness();
    }
    for (Paper paper : this.content) {
      p.add(Double.valueOf(paper.getFitness() / fitnessSum));
    }
    for (int i = 0; i < this.content.size(); i++)
    {
      double radom = Math.random();
      int count = 0;
      
      double area = ((Double)p.get(0)).doubleValue();
      while (radom > area)
      {
        count++;
        


        area += ((Double)p.get(count)).doubleValue();
      }
      nextGeneration.add(Integer.valueOf(count));
    }
    return nextGeneration;
  }
}
